package listbyorder.access101_200.test136;

import java.util.HashSet;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/11 10:43
 */
public class Solution1 {

    // 方法一： 使用数组累加和
    public int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        long sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (!set.contains(nums[i])) {
                set.add(nums[i]);
                sum += 2 * (long) nums[i];
            }
            sum -= nums[i];
        }
        return (int) sum;
    }
}
